// $ANTLR 3.0.1 Lucenedb.g 2011-11-29 19:58:59

package com.googlecode.lucenedb.ql.antlr;
import  com.googlecode.lucenedb.ql.entity.*;
import  com.googlecode.lucenedb.ql.entity.condition.*;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;


import org.antlr.runtime.tree.*;

public class LucenedbParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "KW_SELECT", "ASTERISK", "KW_FROM", "COMMA", "KW_AS", "LPAREN", "RPAREN", "N", "ID", "KW_WHERE", "NUMBER", "EQ", "LTH", "GTH", "NOT_EQ", "LEQ", "GEQ", "QUOTED_STRING", "KW_ORDER", "KW_GROUP", "KW_BY", "KW_LIMIT", "WS", "Letter", "Digit", "PLUS", "MINUS", "DIVIDE", "SQOUT", "'ORDER BY'", "'@'", "'GROUP BY'", "'INDEXORDER'", "'RELEVANCE'", "'OR'", "'AND'", "'NOT'", "'IN'", "'LIKE'", "'BETWEEN'"
    };
    public static final int N=11;
    public static final int SQOUT=32;
    public static final int GTH=17;
    public static final int NUMBER=14;
    public static final int MINUS=30;
    public static final int Digit=28;
    public static final int ID=12;
    public static final int KW_WHERE=13;
    public static final int EOF=-1;
    public static final int KW_LIMIT=25;
    public static final int ASTERISK=5;
    public static final int LPAREN=9;
    public static final int NOT_EQ=18;
    public static final int KW_FROM=6;
    public static final int LTH=16;
    public static final int RPAREN=10;
    public static final int WS=26;
    public static final int KW_SELECT=4;
    public static final int COMMA=7;
    public static final int KW_GROUP=23;
    public static final int KW_BY=24;
    public static final int KW_AS=8;
    public static final int PLUS=29;
    public static final int QUOTED_STRING=21;
    public static final int GEQ=20;
    public static final int EQ=15;
    public static final int Letter=27;
    public static final int DIVIDE=31;
    public static final int KW_ORDER=22;
    public static final int LEQ=19;

        public LucenedbParser(TokenStream input) {
            super(input);
        }
        
    protected TreeAdaptor adaptor = new CommonTreeAdaptor();

    public void setTreeAdaptor(TreeAdaptor adaptor) {
        this.adaptor = adaptor;
    }
    public TreeAdaptor getTreeAdaptor() {
        return adaptor;
    }

    public String[] getTokenNames() { return tokenNames; }
    public String getGrammarFileName() { return "Lucenedb.g"; }

    
    	  private SelectBody selectBody = null;
          public SelectBody getSelectBody(){
             return this.selectBody;
          }


    public static class stemtent_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start stemtent
    // Lucenedb.g:72:1: stemtent : selectStemtent EOF ;
    public final stemtent_return stemtent() throws RecognitionException {
        stemtent_return retval = new stemtent_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token EOF2=null;
        selectStemtent_return selectStemtent1 = null;


        CommonTree EOF2_tree=null;

        try {
            // Lucenedb.g:72:9: ( selectStemtent EOF )
            // Lucenedb.g:73:11: selectStemtent EOF
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_selectStemtent_in_stemtent93);
            selectStemtent1=selectStemtent();
            _fsp--;

            adaptor.addChild(root_0, selectStemtent1.getTree());
            EOF2=(Token)input.LT(1);
            match(input,EOF,FOLLOW_EOF_in_stemtent95); 
            EOF2_tree = (CommonTree)adaptor.create(EOF2);
            adaptor.addChild(root_0, EOF2_tree);


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end stemtent

    public static class selectStemtent_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start selectStemtent
    // Lucenedb.g:76:1: selectStemtent : KW_SELECT ( ASTERISK | selectList[selectBody] ) KW_FROM tabName= identifier ( sqlCondition[selectBody] )? ( groupby[selectBody] )? ( orderby[selectBody] )? ( limit[selectBody] )? ;
    public final selectStemtent_return selectStemtent() throws RecognitionException {
        selectStemtent_return retval = new selectStemtent_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token KW_SELECT3=null;
        Token ASTERISK4=null;
        Token KW_FROM6=null;
        identifier_return tabName = null;

        selectList_return selectList5 = null;

        sqlCondition_return sqlCondition7 = null;

        groupby_return groupby8 = null;

        orderby_return orderby9 = null;

        limit_return limit10 = null;


        CommonTree KW_SELECT3_tree=null;
        CommonTree ASTERISK4_tree=null;
        CommonTree KW_FROM6_tree=null;

        
                 selectBody = new SelectBody();
              
        try {
            // Lucenedb.g:80:7: ( KW_SELECT ( ASTERISK | selectList[selectBody] ) KW_FROM tabName= identifier ( sqlCondition[selectBody] )? ( groupby[selectBody] )? ( orderby[selectBody] )? ( limit[selectBody] )? )
            // Lucenedb.g:80:8: KW_SELECT ( ASTERISK | selectList[selectBody] ) KW_FROM tabName= identifier ( sqlCondition[selectBody] )? ( groupby[selectBody] )? ( orderby[selectBody] )? ( limit[selectBody] )?
            {
            root_0 = (CommonTree)adaptor.nil();

            KW_SELECT3=(Token)input.LT(1);
            match(input,KW_SELECT,FOLLOW_KW_SELECT_in_selectStemtent113); 
            KW_SELECT3_tree = (CommonTree)adaptor.create(KW_SELECT3);
            adaptor.addChild(root_0, KW_SELECT3_tree);

            // Lucenedb.g:80:19: ( ASTERISK | selectList[selectBody] )
            int alt1=2;
            int LA1_0 = input.LA(1);

            if ( (LA1_0==ASTERISK) ) {
                alt1=1;
            }
            else if ( (LA1_0==ID) ) {
                alt1=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("80:19: ( ASTERISK | selectList[selectBody] )", 1, 0, input);

                throw nvae;
            }
            switch (alt1) {
                case 1 :
                    // Lucenedb.g:80:20: ASTERISK
                    {
                    ASTERISK4=(Token)input.LT(1);
                    match(input,ASTERISK,FOLLOW_ASTERISK_in_selectStemtent117); 
                    ASTERISK4_tree = (CommonTree)adaptor.create(ASTERISK4);
                    adaptor.addChild(root_0, ASTERISK4_tree);


                    }
                    break;
                case 2 :
                    // Lucenedb.g:80:29: selectList[selectBody]
                    {
                    pushFollow(FOLLOW_selectList_in_selectStemtent119);
                    selectList5=selectList(selectBody);
                    _fsp--;

                    adaptor.addChild(root_0, selectList5.getTree());

                    }
                    break;

            }

            KW_FROM6=(Token)input.LT(1);
            match(input,KW_FROM,FOLLOW_KW_FROM_in_selectStemtent124); 
            KW_FROM6_tree = (CommonTree)adaptor.create(KW_FROM6);
            adaptor.addChild(root_0, KW_FROM6_tree);

            pushFollow(FOLLOW_identifier_in_selectStemtent131);
            tabName=identifier();
            _fsp--;

            adaptor.addChild(root_0, tabName.getTree());
             selectBody.setTableName(input.toString(tabName.start,tabName.stop));
            // Lucenedb.g:81:7: ( sqlCondition[selectBody] )?
            int alt2=2;
            int LA2_0 = input.LA(1);

            if ( (LA2_0==KW_WHERE) ) {
                alt2=1;
            }
            switch (alt2) {
                case 1 :
                    // Lucenedb.g:81:7: sqlCondition[selectBody]
                    {
                    pushFollow(FOLLOW_sqlCondition_in_selectStemtent143);
                    sqlCondition7=sqlCondition(selectBody);
                    _fsp--;

                    adaptor.addChild(root_0, sqlCondition7.getTree());

                    }
                    break;

            }

            // Lucenedb.g:82:7: ( groupby[selectBody] )?
            int alt3=2;
            int LA3_0 = input.LA(1);

            if ( (LA3_0==35) ) {
                alt3=1;
            }
            switch (alt3) {
                case 1 :
                    // Lucenedb.g:82:7: groupby[selectBody]
                    {
                    pushFollow(FOLLOW_groupby_in_selectStemtent155);
                    groupby8=groupby(selectBody);
                    _fsp--;

                    adaptor.addChild(root_0, groupby8.getTree());

                    }
                    break;

            }

            // Lucenedb.g:83:7: ( orderby[selectBody] )?
            int alt4=2;
            int LA4_0 = input.LA(1);

            if ( (LA4_0==33) ) {
                alt4=1;
            }
            switch (alt4) {
                case 1 :
                    // Lucenedb.g:83:7: orderby[selectBody]
                    {
                    pushFollow(FOLLOW_orderby_in_selectStemtent166);
                    orderby9=orderby(selectBody);
                    _fsp--;

                    adaptor.addChild(root_0, orderby9.getTree());

                    }
                    break;

            }

            // Lucenedb.g:84:7: ( limit[selectBody] )?
            int alt5=2;
            int LA5_0 = input.LA(1);

            if ( (LA5_0==KW_LIMIT) ) {
                alt5=1;
            }
            switch (alt5) {
                case 1 :
                    // Lucenedb.g:84:7: limit[selectBody]
                    {
                    pushFollow(FOLLOW_limit_in_selectStemtent179);
                    limit10=limit(selectBody);
                    _fsp--;

                    adaptor.addChild(root_0, limit10.getTree());

                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end selectStemtent

    public static class selectList_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start selectList
    // Lucenedb.g:87:1: selectList[SelectBody selectBody] : selectItem[columns,i++] ( COMMA selectItem[columns,i++] )* ;
    public final selectList_return selectList(SelectBody selectBody) throws RecognitionException {
        selectList_return retval = new selectList_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token COMMA12=null;
        selectItem_return selectItem11 = null;

        selectItem_return selectItem13 = null;


        CommonTree COMMA12_tree=null;

        
                 List<Column> columns = new ArrayList<Column>();
                 selectBody.setColumns(columns);
                 int i = 0;
               
        try {
            // Lucenedb.g:93:8: ( selectItem[columns,i++] ( COMMA selectItem[columns,i++] )* )
            // Lucenedb.g:93:11: selectItem[columns,i++] ( COMMA selectItem[columns,i++] )*
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_selectItem_in_selectList203);
            selectItem11=selectItem(columns, i++);
            _fsp--;

            adaptor.addChild(root_0, selectItem11.getTree());
            // Lucenedb.g:93:35: ( COMMA selectItem[columns,i++] )*
            loop6:
            do {
                int alt6=2;
                int LA6_0 = input.LA(1);

                if ( (LA6_0==COMMA) ) {
                    alt6=1;
                }


                switch (alt6) {
            	case 1 :
            	    // Lucenedb.g:93:36: COMMA selectItem[columns,i++]
            	    {
            	    COMMA12=(Token)input.LT(1);
            	    match(input,COMMA,FOLLOW_COMMA_in_selectList207); 
            	    COMMA12_tree = (CommonTree)adaptor.create(COMMA12);
            	    adaptor.addChild(root_0, COMMA12_tree);

            	    pushFollow(FOLLOW_selectItem_in_selectList209);
            	    selectItem13=selectItem(columns, i++);
            	    _fsp--;

            	    adaptor.addChild(root_0, selectItem13.getTree());

            	    }
            	    break;

            	default :
            	    break loop6;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end selectList

    public static class selectItem_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start selectItem
    // Lucenedb.g:98:1: selectItem[List<Column> columns,int index] : columnItem[column] ( ( KW_AS )* aliasName= identifier )* ;
    public final selectItem_return selectItem(List<Column> columns, int index) throws RecognitionException {
        selectItem_return retval = new selectItem_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token KW_AS15=null;
        identifier_return aliasName = null;

        columnItem_return columnItem14 = null;


        CommonTree KW_AS15_tree=null;

         
              Column column = new Column(); 
              column.setIndex(columns.size());
              columns.add(column);
           
        try {
            // Lucenedb.g:104:5: ( columnItem[column] ( ( KW_AS )* aliasName= identifier )* )
            // Lucenedb.g:105:6: columnItem[column] ( ( KW_AS )* aliasName= identifier )*
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_columnItem_in_selectItem264);
            columnItem14=columnItem(column);
            _fsp--;

            adaptor.addChild(root_0, columnItem14.getTree());
            // Lucenedb.g:105:25: ( ( KW_AS )* aliasName= identifier )*
            loop8:
            do {
                int alt8=2;
                int LA8_0 = input.LA(1);

                if ( (LA8_0==KW_AS||LA8_0==ID) ) {
                    alt8=1;
                }


                switch (alt8) {
            	case 1 :
            	    // Lucenedb.g:105:26: ( KW_AS )* aliasName= identifier
            	    {
            	    // Lucenedb.g:105:26: ( KW_AS )*
            	    loop7:
            	    do {
            	        int alt7=2;
            	        int LA7_0 = input.LA(1);

            	        if ( (LA7_0==KW_AS) ) {
            	            alt7=1;
            	        }


            	        switch (alt7) {
            	    	case 1 :
            	    	    // Lucenedb.g:105:26: KW_AS
            	    	    {
            	    	    KW_AS15=(Token)input.LT(1);
            	    	    match(input,KW_AS,FOLLOW_KW_AS_in_selectItem268); 
            	    	    KW_AS15_tree = (CommonTree)adaptor.create(KW_AS15);
            	    	    adaptor.addChild(root_0, KW_AS15_tree);


            	    	    }
            	    	    break;

            	    	default :
            	    	    break loop7;
            	        }
            	    } while (true);

            	    pushFollow(FOLLOW_identifier_in_selectItem275);
            	    aliasName=identifier();
            	    _fsp--;

            	    adaptor.addChild(root_0, aliasName.getTree());
            	    column.setAliasName(input.toString(aliasName.start,aliasName.stop));

            	    }
            	    break;

            	default :
            	    break loop8;
                }
            } while (true);

            
            	           
                 

            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end selectItem

    public static class columnItem_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start columnItem
    // Lucenedb.g:113:1: columnItem[Column column] : (colName1= identifier | funText= functionColumnItem[column] );
    public final columnItem_return columnItem(Column column) throws RecognitionException {
        columnItem_return retval = new columnItem_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        identifier_return colName1 = null;

        functionColumnItem_return funText = null;



        try {
            // Lucenedb.g:114:1: (colName1= identifier | funText= functionColumnItem[column] )
            int alt9=2;
            int LA9_0 = input.LA(1);

            if ( (LA9_0==ID) ) {
                int LA9_1 = input.LA(2);

                if ( ((LA9_1>=KW_FROM && LA9_1<=KW_AS)||LA9_1==ID) ) {
                    alt9=1;
                }
                else if ( (LA9_1==LPAREN) ) {
                    alt9=2;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("113:1: columnItem[Column column] : (colName1= identifier | funText= functionColumnItem[column] );", 9, 1, input);

                    throw nvae;
                }
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("113:1: columnItem[Column column] : (colName1= identifier | funText= functionColumnItem[column] );", 9, 0, input);

                throw nvae;
            }
            switch (alt9) {
                case 1 :
                    // Lucenedb.g:114:6: colName1= identifier
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_identifier_in_columnItem318);
                    colName1=identifier();
                    _fsp--;

                    adaptor.addChild(root_0, colName1.getTree());
                    
                    	           column.setName(input.toString(colName1.start,colName1.stop));
                    	           column.setFieldName(input.toString(colName1.start,colName1.stop));
                    	      

                    }
                    break;
                case 2 :
                    // Lucenedb.g:120:6: funText= functionColumnItem[column]
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_functionColumnItem_in_columnItem341);
                    funText=functionColumnItem(column);
                    _fsp--;

                    adaptor.addChild(root_0, funText.getTree());
                    
                    	       column.setName(input.toString(funText.start,funText.stop));
                    	    

                    }
                    break;

            }
            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end columnItem

    public static class functionColumnItem_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start functionColumnItem
    // Lucenedb.g:126:1: functionColumnItem[Column column] : funName= identifier LPAREN args0= text ( COMMA args= text )* RPAREN ;
    public final functionColumnItem_return functionColumnItem(Column column) throws RecognitionException {
        functionColumnItem_return retval = new functionColumnItem_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token LPAREN16=null;
        Token COMMA17=null;
        Token RPAREN18=null;
        identifier_return funName = null;

        text_return args0 = null;

        text_return args = null;


        CommonTree LPAREN16_tree=null;
        CommonTree COMMA17_tree=null;
        CommonTree RPAREN18_tree=null;

        try {
            // Lucenedb.g:127:2: (funName= identifier LPAREN args0= text ( COMMA args= text )* RPAREN )
            // Lucenedb.g:128:2: funName= identifier LPAREN args0= text ( COMMA args= text )* RPAREN
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_identifier_in_functionColumnItem366);
            funName=identifier();
            _fsp--;

            adaptor.addChild(root_0, funName.getTree());
            LPAREN16=(Token)input.LT(1);
            match(input,LPAREN,FOLLOW_LPAREN_in_functionColumnItem368); 
            LPAREN16_tree = (CommonTree)adaptor.create(LPAREN16);
            adaptor.addChild(root_0, LPAREN16_tree);

            pushFollow(FOLLOW_text_in_functionColumnItem372);
            args0=text();
            _fsp--;

            adaptor.addChild(root_0, args0.getTree());
             column.addArgs(input.toString(args0.start,args0.stop)); column.setFieldName(input.toString(args0.start,args0.stop));
            // Lucenedb.g:129:2: ( COMMA args= text )*
            loop10:
            do {
                int alt10=2;
                int LA10_0 = input.LA(1);

                if ( (LA10_0==COMMA) ) {
                    alt10=1;
                }


                switch (alt10) {
            	case 1 :
            	    // Lucenedb.g:129:3: COMMA args= text
            	    {
            	    COMMA17=(Token)input.LT(1);
            	    match(input,COMMA,FOLLOW_COMMA_in_functionColumnItem379); 
            	    COMMA17_tree = (CommonTree)adaptor.create(COMMA17);
            	    adaptor.addChild(root_0, COMMA17_tree);

            	    pushFollow(FOLLOW_text_in_functionColumnItem383);
            	    args=text();
            	    _fsp--;

            	    adaptor.addChild(root_0, args.getTree());
            	     column.addArgs(input.toString(args.start,args.stop)); 

            	    }
            	    break;

            	default :
            	    break loop10;
                }
            } while (true);

            RPAREN18=(Token)input.LT(1);
            match(input,RPAREN,FOLLOW_RPAREN_in_functionColumnItem393); 
            RPAREN18_tree = (CommonTree)adaptor.create(RPAREN18);
            adaptor.addChild(root_0, RPAREN18_tree);

            
            	    column.setFuntionName(input.toString(funName.start,funName.stop));
            	

            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end functionColumnItem

    public static class orderby_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start orderby
    // Lucenedb.g:139:1: orderby[SelectBody selectBody] : 'ORDER BY' orderStr[expr] ( COMMA orderStr[expr] )* ;
    public final orderby_return orderby(SelectBody selectBody) throws RecognitionException {
        orderby_return retval = new orderby_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token string_literal19=null;
        Token COMMA21=null;
        orderStr_return orderStr20 = null;

        orderStr_return orderStr22 = null;


        CommonTree string_literal19_tree=null;
        CommonTree COMMA21_tree=null;

        
                OrderByExpr expr = new OrderByExpr();
                selectBody.setOrderByExpr(expr);
            
        try {
            // Lucenedb.g:144:5: ( 'ORDER BY' orderStr[expr] ( COMMA orderStr[expr] )* )
            // Lucenedb.g:145:7: 'ORDER BY' orderStr[expr] ( COMMA orderStr[expr] )*
            {
            root_0 = (CommonTree)adaptor.nil();

            string_literal19=(Token)input.LT(1);
            match(input,33,FOLLOW_33_in_orderby430); 
            string_literal19_tree = (CommonTree)adaptor.create(string_literal19);
            adaptor.addChild(root_0, string_literal19_tree);

            pushFollow(FOLLOW_orderStr_in_orderby434);
            orderStr20=orderStr(expr);
            _fsp--;

            adaptor.addChild(root_0, orderStr20.getTree());
            // Lucenedb.g:145:36: ( COMMA orderStr[expr] )*
            loop11:
            do {
                int alt11=2;
                int LA11_0 = input.LA(1);

                if ( (LA11_0==COMMA) ) {
                    alt11=1;
                }


                switch (alt11) {
            	case 1 :
            	    // Lucenedb.g:145:37: COMMA orderStr[expr]
            	    {
            	    COMMA21=(Token)input.LT(1);
            	    match(input,COMMA,FOLLOW_COMMA_in_orderby439); 
            	    COMMA21_tree = (CommonTree)adaptor.create(COMMA21);
            	    adaptor.addChild(root_0, COMMA21_tree);

            	    pushFollow(FOLLOW_orderStr_in_orderby441);
            	    orderStr22=orderStr(expr);
            	    _fsp--;

            	    adaptor.addChild(root_0, orderStr22.getTree());

            	    }
            	    break;

            	default :
            	    break loop11;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end orderby

    public static class orderStr_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start orderStr
    // Lucenedb.g:148:1: orderStr[OrderByExpr expr] : v1= identifier ( '@' v3= identifier )* (v2= identifier )* ;
    public final orderStr_return orderStr(OrderByExpr expr) throws RecognitionException {
        orderStr_return retval = new orderStr_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token char_literal23=null;
        identifier_return v1 = null;

        identifier_return v3 = null;

        identifier_return v2 = null;


        CommonTree char_literal23_tree=null;

        
                Order order = new Order();
                expr.addValue(order);
            
        try {
            // Lucenedb.g:153:1: (v1= identifier ( '@' v3= identifier )* (v2= identifier )* )
            // Lucenedb.g:154:3: v1= identifier ( '@' v3= identifier )* (v2= identifier )*
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_identifier_in_orderStr480);
            v1=identifier();
            _fsp--;

            adaptor.addChild(root_0, v1.getTree());
             order.setName(input.toString(v1.start,v1.stop));
            // Lucenedb.g:154:46: ( '@' v3= identifier )*
            loop12:
            do {
                int alt12=2;
                int LA12_0 = input.LA(1);

                if ( (LA12_0==34) ) {
                    alt12=1;
                }


                switch (alt12) {
            	case 1 :
            	    // Lucenedb.g:154:47: '@' v3= identifier
            	    {
            	    char_literal23=(Token)input.LT(1);
            	    match(input,34,FOLLOW_34_in_orderStr486); 
            	    char_literal23_tree = (CommonTree)adaptor.create(char_literal23);
            	    adaptor.addChild(root_0, char_literal23_tree);

            	    pushFollow(FOLLOW_identifier_in_orderStr491);
            	    v3=identifier();
            	    _fsp--;

            	    adaptor.addChild(root_0, v3.getTree());
            	     order.setDataType(input.toString(v3.start,v3.stop));

            	    }
            	    break;

            	default :
            	    break loop12;
                }
            } while (true);

            // Lucenedb.g:154:102: (v2= identifier )*
            loop13:
            do {
                int alt13=2;
                int LA13_0 = input.LA(1);

                if ( (LA13_0==ID) ) {
                    alt13=1;
                }


                switch (alt13) {
            	case 1 :
            	    // Lucenedb.g:154:104: v2= identifier
            	    {
            	    pushFollow(FOLLOW_identifier_in_orderStr503);
            	    v2=identifier();
            	    _fsp--;

            	    adaptor.addChild(root_0, v2.getTree());
            	     order.setSort(input.toString(v2.start,v2.stop));

            	    }
            	    break;

            	default :
            	    break loop13;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end orderStr

    public static class groupby_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start groupby
    // Lucenedb.g:158:1: groupby[SelectBody selectBody] : 'GROUP BY' v1= identifier ( '@' sort= groupSort )* ;
    public final groupby_return groupby(SelectBody selectBody) throws RecognitionException {
        groupby_return retval = new groupby_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token string_literal24=null;
        Token char_literal25=null;
        identifier_return v1 = null;

        groupSort_return sort = null;


        CommonTree string_literal24_tree=null;
        CommonTree char_literal25_tree=null;

        
                  GroupByExpr expr = new GroupByExpr();
                  selectBody.setGroupByExpr(expr);
           
        try {
            // Lucenedb.g:163:4: ( 'GROUP BY' v1= identifier ( '@' sort= groupSort )* )
            // Lucenedb.g:164:3: 'GROUP BY' v1= identifier ( '@' sort= groupSort )*
            {
            root_0 = (CommonTree)adaptor.nil();

            string_literal24=(Token)input.LT(1);
            match(input,35,FOLLOW_35_in_groupby532); 
            string_literal24_tree = (CommonTree)adaptor.create(string_literal24);
            adaptor.addChild(root_0, string_literal24_tree);

            pushFollow(FOLLOW_identifier_in_groupby536);
            v1=identifier();
            _fsp--;

            adaptor.addChild(root_0, v1.getTree());
             expr.setFieldName(input.toString(v1.start,v1.stop)); 
            // Lucenedb.g:164:63: ( '@' sort= groupSort )*
            loop14:
            do {
                int alt14=2;
                int LA14_0 = input.LA(1);

                if ( (LA14_0==34) ) {
                    alt14=1;
                }


                switch (alt14) {
            	case 1 :
            	    // Lucenedb.g:164:64: '@' sort= groupSort
            	    {
            	    char_literal25=(Token)input.LT(1);
            	    match(input,34,FOLLOW_34_in_groupby543); 
            	    char_literal25_tree = (CommonTree)adaptor.create(char_literal25);
            	    adaptor.addChild(root_0, char_literal25_tree);

            	    pushFollow(FOLLOW_groupSort_in_groupby548);
            	    sort=groupSort();
            	    _fsp--;

            	    adaptor.addChild(root_0, sort.getTree());
            	    expr.setSort(input.toString(sort.start,sort.stop));

            	    }
            	    break;

            	default :
            	    break loop14;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end groupby

    public static class groupSort_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start groupSort
    // Lucenedb.g:167:1: groupSort : ( 'INDEXORDER' | 'RELEVANCE' );
    public final groupSort_return groupSort() throws RecognitionException {
        groupSort_return retval = new groupSort_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token set26=null;

        CommonTree set26_tree=null;

        try {
            // Lucenedb.g:167:10: ( 'INDEXORDER' | 'RELEVANCE' )
            // Lucenedb.g:
            {
            root_0 = (CommonTree)adaptor.nil();

            set26=(Token)input.LT(1);
            if ( (input.LA(1)>=36 && input.LA(1)<=37) ) {
                input.consume();
                adaptor.addChild(root_0, adaptor.create(set26));
                errorRecovery=false;
            }
            else {
                MismatchedSetException mse =
                    new MismatchedSetException(null,input);
                recoverFromMismatchedSet(input,mse,FOLLOW_set_in_groupSort0);    throw mse;
            }


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end groupSort

    public static class limit_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start limit
    // Lucenedb.g:171:1: limit[SelectBody selectBody] : 'LIMIT' v1= N ( COMMA v2= N )* ;
    public final limit_return limit(SelectBody selectBody) throws RecognitionException {
        limit_return retval = new limit_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token v1=null;
        Token v2=null;
        Token string_literal27=null;
        Token COMMA28=null;

        CommonTree v1_tree=null;
        CommonTree v2_tree=null;
        CommonTree string_literal27_tree=null;
        CommonTree COMMA28_tree=null;

        
                  LimitExpr expr = new LimitExpr();
                  selectBody.setLimitExpr(expr);
           
        try {
            // Lucenedb.g:176:4: ( 'LIMIT' v1= N ( COMMA v2= N )* )
            // Lucenedb.g:177:6: 'LIMIT' v1= N ( COMMA v2= N )*
            {
            root_0 = (CommonTree)adaptor.nil();

            string_literal27=(Token)input.LT(1);
            match(input,KW_LIMIT,FOLLOW_KW_LIMIT_in_limit596); 
            string_literal27_tree = (CommonTree)adaptor.create(string_literal27);
            adaptor.addChild(root_0, string_literal27_tree);

            v1=(Token)input.LT(1);
            match(input,N,FOLLOW_N_in_limit601); 
            v1_tree = (CommonTree)adaptor.create(v1);
            adaptor.addChild(root_0, v1_tree);

            expr.setStart(Integer.parseInt(v1.getText()));
            // Lucenedb.g:177:66: ( COMMA v2= N )*
            loop15:
            do {
                int alt15=2;
                int LA15_0 = input.LA(1);

                if ( (LA15_0==COMMA) ) {
                    alt15=1;
                }


                switch (alt15) {
            	case 1 :
            	    // Lucenedb.g:177:67: COMMA v2= N
            	    {
            	    COMMA28=(Token)input.LT(1);
            	    match(input,COMMA,FOLLOW_COMMA_in_limit607); 
            	    COMMA28_tree = (CommonTree)adaptor.create(COMMA28);
            	    adaptor.addChild(root_0, COMMA28_tree);

            	    v2=(Token)input.LT(1);
            	    match(input,N,FOLLOW_N_in_limit611); 
            	    v2_tree = (CommonTree)adaptor.create(v2);
            	    adaptor.addChild(root_0, v2_tree);

            	    expr.setEnd(Integer.parseInt(v2.getText()));

            	    }
            	    break;

            	default :
            	    break loop15;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end limit

    public static class identifier_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start identifier
    // Lucenedb.g:182:1: identifier : ID ;
    public final identifier_return identifier() throws RecognitionException {
        identifier_return retval = new identifier_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token ID29=null;

        CommonTree ID29_tree=null;

        try {
            // Lucenedb.g:183:2: ( ID )
            // Lucenedb.g:183:4: ID
            {
            root_0 = (CommonTree)adaptor.nil();

            ID29=(Token)input.LT(1);
            match(input,ID,FOLLOW_ID_in_identifier627); 
            ID29_tree = (CommonTree)adaptor.create(ID29);
            adaptor.addChild(root_0, ID29_tree);


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end identifier

    public static class sqlCondition_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start sqlCondition
    // Lucenedb.g:193:1: sqlCondition[SelectBody selectBody] : KW_WHERE condition_or[defConditionGroup,true] ;
    public final sqlCondition_return sqlCondition(SelectBody selectBody) throws RecognitionException {
        sqlCondition_return retval = new sqlCondition_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token KW_WHERE30=null;
        condition_or_return condition_or31 = null;


        CommonTree KW_WHERE30_tree=null;

        try {
            // Lucenedb.g:194:2: ( KW_WHERE condition_or[defConditionGroup,true] )
            // Lucenedb.g:195:2: KW_WHERE condition_or[defConditionGroup,true]
            {
            root_0 = (CommonTree)adaptor.nil();

            
            	   ConditionGroup defConditionGroup  = new ConditionGroup();
            	   defConditionGroup.setCondition(true);
            	   selectBody.setConditionGroup(defConditionGroup);
            	
            KW_WHERE30=(Token)input.LT(1);
            match(input,KW_WHERE,FOLLOW_KW_WHERE_in_sqlCondition651); 
            KW_WHERE30_tree = (CommonTree)adaptor.create(KW_WHERE30);
            adaptor.addChild(root_0, KW_WHERE30_tree);

            pushFollow(FOLLOW_condition_or_in_sqlCondition653);
            condition_or31=condition_or(defConditionGroup, true);
            _fsp--;

            adaptor.addChild(root_0, condition_or31.getTree());

            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end sqlCondition

    public static class condition_or_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start condition_or
    // Lucenedb.g:204:1: condition_or[ConditionGroup conditionGroup,boolean condition] : ca0= condition_and[conditionGroup,condition] ( 'OR' can= condition_and[conditionGroup,false] )* ;
    public final condition_or_return condition_or(ConditionGroup conditionGroup, boolean condition) throws RecognitionException {
        condition_or_return retval = new condition_or_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token string_literal32=null;
        condition_and_return ca0 = null;

        condition_and_return can = null;


        CommonTree string_literal32_tree=null;

        try {
            // Lucenedb.g:205:2: (ca0= condition_and[conditionGroup,condition] ( 'OR' can= condition_and[conditionGroup,false] )* )
            // Lucenedb.g:205:4: ca0= condition_and[conditionGroup,condition] ( 'OR' can= condition_and[conditionGroup,false] )*
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_condition_and_in_condition_or669);
            ca0=condition_and(conditionGroup, condition);
            _fsp--;

            adaptor.addChild(root_0, ca0.getTree());
            // Lucenedb.g:205:48: ( 'OR' can= condition_and[conditionGroup,false] )*
            loop16:
            do {
                int alt16=2;
                int LA16_0 = input.LA(1);

                if ( (LA16_0==38) ) {
                    alt16=1;
                }


                switch (alt16) {
            	case 1 :
            	    // Lucenedb.g:205:50: 'OR' can= condition_and[conditionGroup,false]
            	    {
            	    string_literal32=(Token)input.LT(1);
            	    match(input,38,FOLLOW_38_in_condition_or674); 
            	    string_literal32_tree = (CommonTree)adaptor.create(string_literal32);
            	    adaptor.addChild(root_0, string_literal32_tree);

            	    pushFollow(FOLLOW_condition_and_in_condition_or678);
            	    can=condition_and(conditionGroup, false);
            	    _fsp--;

            	    adaptor.addChild(root_0, can.getTree());

            	    }
            	    break;

            	default :
            	    break loop16;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end condition_or

    public static class condition_and_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start condition_and
    // Lucenedb.g:208:1: condition_and[ConditionGroup conditionGroup,boolean condition] : condition_PAREN[conditionGroup,condition] ( 'AND' condition_PAREN[conditionGroup,true] )* ;
    public final condition_and_return condition_and(ConditionGroup conditionGroup, boolean condition) throws RecognitionException {
        condition_and_return retval = new condition_and_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token string_literal34=null;
        condition_PAREN_return condition_PAREN33 = null;

        condition_PAREN_return condition_PAREN35 = null;


        CommonTree string_literal34_tree=null;

        try {
            // Lucenedb.g:209:2: ( condition_PAREN[conditionGroup,condition] ( 'AND' condition_PAREN[conditionGroup,true] )* )
            // Lucenedb.g:209:3: condition_PAREN[conditionGroup,condition] ( 'AND' condition_PAREN[conditionGroup,true] )*
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_condition_PAREN_in_condition_and693);
            condition_PAREN33=condition_PAREN(conditionGroup, condition);
            _fsp--;

            adaptor.addChild(root_0, condition_PAREN33.getTree());
            // Lucenedb.g:209:45: ( 'AND' condition_PAREN[conditionGroup,true] )*
            loop17:
            do {
                int alt17=2;
                int LA17_0 = input.LA(1);

                if ( (LA17_0==39) ) {
                    alt17=1;
                }


                switch (alt17) {
            	case 1 :
            	    // Lucenedb.g:209:47: 'AND' condition_PAREN[conditionGroup,true]
            	    {
            	    string_literal34=(Token)input.LT(1);
            	    match(input,39,FOLLOW_39_in_condition_and698); 
            	    string_literal34_tree = (CommonTree)adaptor.create(string_literal34);
            	    adaptor.addChild(root_0, string_literal34_tree);

            	    pushFollow(FOLLOW_condition_PAREN_in_condition_and700);
            	    condition_PAREN35=condition_PAREN(conditionGroup, true);
            	    _fsp--;

            	    adaptor.addChild(root_0, condition_PAREN35.getTree());

            	    }
            	    break;

            	default :
            	    break loop17;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end condition_and

    public static class condition_PAREN_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start condition_PAREN
    // Lucenedb.g:213:1: condition_PAREN[ConditionGroup conditionGroup,boolean condition] : ( LPAREN condition_or[childConditionGroup,true] RPAREN | condition_expr[expr] );
    public final condition_PAREN_return condition_PAREN(ConditionGroup conditionGroup, boolean condition) throws RecognitionException {
        condition_PAREN_return retval = new condition_PAREN_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token LPAREN36=null;
        Token RPAREN38=null;
        condition_or_return condition_or37 = null;

        condition_expr_return condition_expr39 = null;


        CommonTree LPAREN36_tree=null;
        CommonTree RPAREN38_tree=null;

        try {
            // Lucenedb.g:214:2: ( LPAREN condition_or[childConditionGroup,true] RPAREN | condition_expr[expr] )
            int alt18=2;
            int LA18_0 = input.LA(1);

            if ( (LA18_0==LPAREN) ) {
                alt18=1;
            }
            else if ( (LA18_0==ID) ) {
                alt18=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("213:1: condition_PAREN[ConditionGroup conditionGroup,boolean condition] : ( LPAREN condition_or[childConditionGroup,true] RPAREN | condition_expr[expr] );", 18, 0, input);

                throw nvae;
            }
            switch (alt18) {
                case 1 :
                    // Lucenedb.g:215:3: LPAREN condition_or[childConditionGroup,true] RPAREN
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    
                    	   ConditionGroup childConditionGroup  = new ConditionGroup();
                    	   childConditionGroup.setCondition(condition);
                    	   childConditionGroup.setIndex(conditionGroup.getChildConditionGroups().size());
                    	   conditionGroup.getChildConditionGroups().add(childConditionGroup);
                    	 
                    LPAREN36=(Token)input.LT(1);
                    match(input,LPAREN,FOLLOW_LPAREN_in_condition_PAREN723); 
                    LPAREN36_tree = (CommonTree)adaptor.create(LPAREN36);
                    adaptor.addChild(root_0, LPAREN36_tree);

                    pushFollow(FOLLOW_condition_or_in_condition_PAREN725);
                    condition_or37=condition_or(childConditionGroup, true);
                    _fsp--;

                    adaptor.addChild(root_0, condition_or37.getTree());
                    RPAREN38=(Token)input.LT(1);
                    match(input,RPAREN,FOLLOW_RPAREN_in_condition_PAREN728); 
                    RPAREN38_tree = (CommonTree)adaptor.create(RPAREN38);
                    adaptor.addChild(root_0, RPAREN38_tree);


                    }
                    break;
                case 2 :
                    // Lucenedb.g:222:5: condition_expr[expr]
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    
                    	       ConditionExpr expr = new ConditionExpr(); 
                    	       expr.setCondition(condition);
                    	       expr.setIndex(conditionGroup.getChildConditionGroups().size());
                    	       conditionGroup.getChildConditionGroups().add(expr);
                    	   
                    pushFollow(FOLLOW_condition_expr_in_condition_PAREN741);
                    condition_expr39=condition_expr(expr);
                    _fsp--;

                    adaptor.addChild(root_0, condition_expr39.getTree());

                    }
                    break;

            }
            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end condition_PAREN

    public static class condition_expr_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start condition_expr
    // Lucenedb.g:233:1: condition_expr[ConditionExpr expr] : nanme= condition_left condition_right[expr] ;
    public final condition_expr_return condition_expr(ConditionExpr expr) throws RecognitionException {
        condition_expr_return retval = new condition_expr_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        condition_left_return nanme = null;

        condition_right_return condition_right40 = null;



        try {
            // Lucenedb.g:235:2: (nanme= condition_left condition_right[expr] )
            // Lucenedb.g:236:3: nanme= condition_left condition_right[expr]
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_condition_left_in_condition_expr772);
            nanme=condition_left();
            _fsp--;

            adaptor.addChild(root_0, nanme.getTree());
            pushFollow(FOLLOW_condition_right_in_condition_expr775);
            condition_right40=condition_right(expr);
            _fsp--;

            adaptor.addChild(root_0, condition_right40.getTree());
            
            	    expr.setName(input.toString(nanme.start,nanme.stop));
            	  

            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end condition_expr

    public static class condition_right_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start condition_right
    // Lucenedb.g:242:1: condition_right[ConditionExpr expr] : ( comp_expr[conditionRight] | in_expr[conditionRight] | like_expr[conditionRight] | between_expr[conditionRight] );
    public final condition_right_return condition_right(ConditionExpr expr) throws RecognitionException {
        condition_right_return retval = new condition_right_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        comp_expr_return comp_expr41 = null;

        in_expr_return in_expr42 = null;

        like_expr_return like_expr43 = null;

        between_expr_return between_expr44 = null;



        
                    ConditionRight  conditionRight = null;
                
        try {
            // Lucenedb.g:246:2: ( comp_expr[conditionRight] | in_expr[conditionRight] | like_expr[conditionRight] | between_expr[conditionRight] )
            int alt19=4;
            switch ( input.LA(1) ) {
            case EQ:
            case LTH:
            case GTH:
            case NOT_EQ:
            case LEQ:
            case GEQ:
                {
                alt19=1;
                }
                break;
            case 40:
                {
                switch ( input.LA(2) ) {
                case 41:
                    {
                    alt19=2;
                    }
                    break;
                case 42:
                    {
                    alt19=3;
                    }
                    break;
                case 43:
                    {
                    alt19=4;
                    }
                    break;
                default:
                    NoViableAltException nvae =
                        new NoViableAltException("242:1: condition_right[ConditionExpr expr] : ( comp_expr[conditionRight] | in_expr[conditionRight] | like_expr[conditionRight] | between_expr[conditionRight] );", 19, 2, input);

                    throw nvae;
                }

                }
                break;
            case 41:
                {
                alt19=2;
                }
                break;
            case 42:
                {
                alt19=3;
                }
                break;
            case 43:
                {
                alt19=4;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("242:1: condition_right[ConditionExpr expr] : ( comp_expr[conditionRight] | in_expr[conditionRight] | like_expr[conditionRight] | between_expr[conditionRight] );", 19, 0, input);

                throw nvae;
            }

            switch (alt19) {
                case 1 :
                    // Lucenedb.g:246:4: comp_expr[conditionRight]
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    conditionRight = new CompareCondition(); expr.setConditionRight(conditionRight);
                    pushFollow(FOLLOW_comp_expr_in_condition_right810);
                    comp_expr41=comp_expr(conditionRight);
                    _fsp--;

                    adaptor.addChild(root_0, comp_expr41.getTree());

                    }
                    break;
                case 2 :
                    // Lucenedb.g:247:10: in_expr[conditionRight]
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    conditionRight = new InCondition(); expr.setConditionRight(conditionRight);
                    pushFollow(FOLLOW_in_expr_in_condition_right826);
                    in_expr42=in_expr(conditionRight);
                    _fsp--;

                    adaptor.addChild(root_0, in_expr42.getTree());

                    }
                    break;
                case 3 :
                    // Lucenedb.g:248:10: like_expr[conditionRight]
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    conditionRight = new LikeCondition(); expr.setConditionRight(conditionRight);
                    pushFollow(FOLLOW_like_expr_in_condition_right841);
                    like_expr43=like_expr(conditionRight);
                    _fsp--;

                    adaptor.addChild(root_0, like_expr43.getTree());

                    }
                    break;
                case 4 :
                    // Lucenedb.g:249:10: between_expr[conditionRight]
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    conditionRight = new BetweenCondition(); expr.setConditionRight(conditionRight);
                    pushFollow(FOLLOW_between_expr_in_condition_right856);
                    between_expr44=between_expr(conditionRight);
                    _fsp--;

                    adaptor.addChild(root_0, between_expr44.getTree());

                    }
                    break;

            }
            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end condition_right

    public static class comp_expr_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start comp_expr
    // Lucenedb.g:252:1: comp_expr[ConditionRight conditionRight] : op= relational_op val= value ;
    public final comp_expr_return comp_expr(ConditionRight conditionRight) throws RecognitionException {
        comp_expr_return retval = new comp_expr_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        relational_op_return op = null;

        value_return val = null;



        try {
            // Lucenedb.g:253:2: (op= relational_op val= value )
            // Lucenedb.g:253:4: op= relational_op val= value
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_relational_op_in_comp_expr875);
            op=relational_op();
            _fsp--;

            adaptor.addChild(root_0, op.getTree());
            pushFollow(FOLLOW_value_in_comp_expr880);
            val=value();
            _fsp--;

            adaptor.addChild(root_0, val.getTree());
            
            	     
            	     ((CompareCondition)conditionRight).setCop(input.toString(op.start,op.stop));
            	     ((CompareCondition)conditionRight).setValue(input.toString(val.start,val.stop));
            	  
            	  

            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end comp_expr

    public static class value_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start value
    // Lucenedb.g:263:1: value : ( N | NUMBER | quoted_string );
    public final value_return value() throws RecognitionException {
        value_return retval = new value_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token N45=null;
        Token NUMBER46=null;
        quoted_string_return quoted_string47 = null;


        CommonTree N45_tree=null;
        CommonTree NUMBER46_tree=null;

        try {
            // Lucenedb.g:264:2: ( N | NUMBER | quoted_string )
            int alt20=3;
            switch ( input.LA(1) ) {
            case N:
                {
                alt20=1;
                }
                break;
            case NUMBER:
                {
                alt20=2;
                }
                break;
            case QUOTED_STRING:
                {
                alt20=3;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("263:1: value : ( N | NUMBER | quoted_string );", 20, 0, input);

                throw nvae;
            }

            switch (alt20) {
                case 1 :
                    // Lucenedb.g:264:3: N
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    N45=(Token)input.LT(1);
                    match(input,N,FOLLOW_N_in_value898); 
                    N45_tree = (CommonTree)adaptor.create(N45);
                    adaptor.addChild(root_0, N45_tree);


                    }
                    break;
                case 2 :
                    // Lucenedb.g:265:3: NUMBER
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    NUMBER46=(Token)input.LT(1);
                    match(input,NUMBER,FOLLOW_NUMBER_in_value902); 
                    NUMBER46_tree = (CommonTree)adaptor.create(NUMBER46);
                    adaptor.addChild(root_0, NUMBER46_tree);


                    }
                    break;
                case 3 :
                    // Lucenedb.g:266:3: quoted_string
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_quoted_string_in_value906);
                    quoted_string47=quoted_string();
                    _fsp--;

                    adaptor.addChild(root_0, quoted_string47.getTree());

                    }
                    break;

            }
            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end value

    public static class text_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start text
    // Lucenedb.g:269:1: text : ( ( ( N )* ( NUMBER )* ( ID )* ) | quoted_string );
    public final text_return text() throws RecognitionException {
        text_return retval = new text_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token N48=null;
        Token NUMBER49=null;
        Token ID50=null;
        quoted_string_return quoted_string51 = null;


        CommonTree N48_tree=null;
        CommonTree NUMBER49_tree=null;
        CommonTree ID50_tree=null;

        try {
            // Lucenedb.g:269:7: ( ( ( N )* ( NUMBER )* ( ID )* ) | quoted_string )
            int alt24=2;
            int LA24_0 = input.LA(1);

            if ( (LA24_0==COMMA||(LA24_0>=RPAREN && LA24_0<=ID)||LA24_0==NUMBER) ) {
                alt24=1;
            }
            else if ( (LA24_0==QUOTED_STRING) ) {
                alt24=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("269:1: text : ( ( ( N )* ( NUMBER )* ( ID )* ) | quoted_string );", 24, 0, input);

                throw nvae;
            }
            switch (alt24) {
                case 1 :
                    // Lucenedb.g:269:8: ( ( N )* ( NUMBER )* ( ID )* )
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    // Lucenedb.g:269:8: ( ( N )* ( NUMBER )* ( ID )* )
                    // Lucenedb.g:269:10: ( N )* ( NUMBER )* ( ID )*
                    {
                    // Lucenedb.g:269:10: ( N )*
                    loop21:
                    do {
                        int alt21=2;
                        int LA21_0 = input.LA(1);

                        if ( (LA21_0==N) ) {
                            alt21=1;
                        }


                        switch (alt21) {
                    	case 1 :
                    	    // Lucenedb.g:269:10: N
                    	    {
                    	    N48=(Token)input.LT(1);
                    	    match(input,N,FOLLOW_N_in_text919); 
                    	    N48_tree = (CommonTree)adaptor.create(N48);
                    	    adaptor.addChild(root_0, N48_tree);


                    	    }
                    	    break;

                    	default :
                    	    break loop21;
                        }
                    } while (true);

                    // Lucenedb.g:269:14: ( NUMBER )*
                    loop22:
                    do {
                        int alt22=2;
                        int LA22_0 = input.LA(1);

                        if ( (LA22_0==NUMBER) ) {
                            alt22=1;
                        }


                        switch (alt22) {
                    	case 1 :
                    	    // Lucenedb.g:269:14: NUMBER
                    	    {
                    	    NUMBER49=(Token)input.LT(1);
                    	    match(input,NUMBER,FOLLOW_NUMBER_in_text923); 
                    	    NUMBER49_tree = (CommonTree)adaptor.create(NUMBER49);
                    	    adaptor.addChild(root_0, NUMBER49_tree);


                    	    }
                    	    break;

                    	default :
                    	    break loop22;
                        }
                    } while (true);

                    // Lucenedb.g:269:23: ( ID )*
                    loop23:
                    do {
                        int alt23=2;
                        int LA23_0 = input.LA(1);

                        if ( (LA23_0==ID) ) {
                            alt23=1;
                        }


                        switch (alt23) {
                    	case 1 :
                    	    // Lucenedb.g:269:23: ID
                    	    {
                    	    ID50=(Token)input.LT(1);
                    	    match(input,ID,FOLLOW_ID_in_text927); 
                    	    ID50_tree = (CommonTree)adaptor.create(ID50);
                    	    adaptor.addChild(root_0, ID50_tree);


                    	    }
                    	    break;

                    	default :
                    	    break loop23;
                        }
                    } while (true);


                    }


                    }
                    break;
                case 2 :
                    // Lucenedb.g:269:30: quoted_string
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_quoted_string_in_text933);
                    quoted_string51=quoted_string();
                    _fsp--;

                    adaptor.addChild(root_0, quoted_string51.getTree());

                    }
                    break;

            }
            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end text

    public static class in_expr_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start in_expr
    // Lucenedb.g:272:2: in_expr[ConditionRight conditionRight] : (not= 'NOT' )? 'IN' LPAREN v1= value ( COMMA v2= value )* RPAREN ;
    public final in_expr_return in_expr(ConditionRight conditionRight) throws RecognitionException {
        in_expr_return retval = new in_expr_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token not=null;
        Token string_literal52=null;
        Token LPAREN53=null;
        Token COMMA54=null;
        Token RPAREN55=null;
        value_return v1 = null;

        value_return v2 = null;


        CommonTree not_tree=null;
        CommonTree string_literal52_tree=null;
        CommonTree LPAREN53_tree=null;
        CommonTree COMMA54_tree=null;
        CommonTree RPAREN55_tree=null;

        try {
            // Lucenedb.g:273:2: ( (not= 'NOT' )? 'IN' LPAREN v1= value ( COMMA v2= value )* RPAREN )
            // Lucenedb.g:274:5: (not= 'NOT' )? 'IN' LPAREN v1= value ( COMMA v2= value )* RPAREN
            {
            root_0 = (CommonTree)adaptor.nil();

            // Lucenedb.g:274:8: (not= 'NOT' )?
            int alt25=2;
            int LA25_0 = input.LA(1);

            if ( (LA25_0==40) ) {
                alt25=1;
            }
            switch (alt25) {
                case 1 :
                    // Lucenedb.g:274:8: not= 'NOT'
                    {
                    not=(Token)input.LT(1);
                    match(input,40,FOLLOW_40_in_in_expr959); 
                    not_tree = (CommonTree)adaptor.create(not);
                    adaptor.addChild(root_0, not_tree);


                    }
                    break;

            }

            
                              if(not!=null){
                                   ((InCondition)conditionRight).setNot(true);
                              }else{
                                   ((InCondition)conditionRight).setNot(false);
                              }
                
                            
            string_literal52=(Token)input.LT(1);
            match(input,41,FOLLOW_41_in_in_expr972); 
            string_literal52_tree = (CommonTree)adaptor.create(string_literal52);
            adaptor.addChild(root_0, string_literal52_tree);

            LPAREN53=(Token)input.LT(1);
            match(input,LPAREN,FOLLOW_LPAREN_in_in_expr975); 
            LPAREN53_tree = (CommonTree)adaptor.create(LPAREN53);
            adaptor.addChild(root_0, LPAREN53_tree);

            pushFollow(FOLLOW_value_in_in_expr979);
            v1=value();
            _fsp--;

            adaptor.addChild(root_0, v1.getTree());
            ((InCondition)conditionRight).addValue(input.toString(v1.start,v1.stop));
            // Lucenedb.g:282:78: ( COMMA v2= value )*
            loop26:
            do {
                int alt26=2;
                int LA26_0 = input.LA(1);

                if ( (LA26_0==COMMA) ) {
                    alt26=1;
                }


                switch (alt26) {
            	case 1 :
            	    // Lucenedb.g:282:79: COMMA v2= value
            	    {
            	    COMMA54=(Token)input.LT(1);
            	    match(input,COMMA,FOLLOW_COMMA_in_in_expr983); 
            	    COMMA54_tree = (CommonTree)adaptor.create(COMMA54);
            	    adaptor.addChild(root_0, COMMA54_tree);

            	    pushFollow(FOLLOW_value_in_in_expr987);
            	    v2=value();
            	    _fsp--;

            	    adaptor.addChild(root_0, v2.getTree());
            	    ((InCondition)conditionRight).addValue(input.toString(v2.start,v2.stop));

            	    }
            	    break;

            	default :
            	    break loop26;
                }
            } while (true);

            RPAREN55=(Token)input.LT(1);
            match(input,RPAREN,FOLLOW_RPAREN_in_in_expr993); 
            RPAREN55_tree = (CommonTree)adaptor.create(RPAREN55);
            adaptor.addChild(root_0, RPAREN55_tree);


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end in_expr

    public static class like_expr_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start like_expr
    // Lucenedb.g:285:2: like_expr[ConditionRight conditionRight] : (not= 'NOT' )? 'LIKE' val= quoted_string ;
    public final like_expr_return like_expr(ConditionRight conditionRight) throws RecognitionException {
        like_expr_return retval = new like_expr_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token not=null;
        Token string_literal56=null;
        quoted_string_return val = null;


        CommonTree not_tree=null;
        CommonTree string_literal56_tree=null;

        try {
            // Lucenedb.g:286:3: ( (not= 'NOT' )? 'LIKE' val= quoted_string )
            // Lucenedb.g:287:3: (not= 'NOT' )? 'LIKE' val= quoted_string
            {
            root_0 = (CommonTree)adaptor.nil();

            // Lucenedb.g:287:6: (not= 'NOT' )?
            int alt27=2;
            int LA27_0 = input.LA(1);

            if ( (LA27_0==40) ) {
                alt27=1;
            }
            switch (alt27) {
                case 1 :
                    // Lucenedb.g:287:6: not= 'NOT'
                    {
                    not=(Token)input.LT(1);
                    match(input,40,FOLLOW_40_in_like_expr1018); 
                    not_tree = (CommonTree)adaptor.create(not);
                    adaptor.addChild(root_0, not_tree);


                    }
                    break;

            }

            
                              if(not!=null){
                                   ((LikeCondition)conditionRight).setNot(true);
                              }else{
                                   ((LikeCondition)conditionRight).setNot(false);
                              }
                
                    
            string_literal56=(Token)input.LT(1);
            match(input,42,FOLLOW_42_in_like_expr1041); 
            string_literal56_tree = (CommonTree)adaptor.create(string_literal56);
            adaptor.addChild(root_0, string_literal56_tree);

            pushFollow(FOLLOW_quoted_string_in_like_expr1046);
            val=quoted_string();
            _fsp--;

            adaptor.addChild(root_0, val.getTree());
            ((LikeCondition)conditionRight).setValue(input.toString(val.start,val.stop));

            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end like_expr

    public static class between_expr_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start between_expr
    // Lucenedb.g:301:2: between_expr[ConditionRight conditionRight] : (not= 'NOT' )? 'BETWEEN' LPAREN s= ( N | NUMBER ) COMMA e= ( N | NUMBER ) RPAREN ;
    public final between_expr_return between_expr(ConditionRight conditionRight) throws RecognitionException {
        between_expr_return retval = new between_expr_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token not=null;
        Token s=null;
        Token e=null;
        Token string_literal57=null;
        Token LPAREN58=null;
        Token COMMA59=null;
        Token RPAREN60=null;

        CommonTree not_tree=null;
        CommonTree s_tree=null;
        CommonTree e_tree=null;
        CommonTree string_literal57_tree=null;
        CommonTree LPAREN58_tree=null;
        CommonTree COMMA59_tree=null;
        CommonTree RPAREN60_tree=null;

        try {
            // Lucenedb.g:301:45: ( (not= 'NOT' )? 'BETWEEN' LPAREN s= ( N | NUMBER ) COMMA e= ( N | NUMBER ) RPAREN )
            // Lucenedb.g:302:7: (not= 'NOT' )? 'BETWEEN' LPAREN s= ( N | NUMBER ) COMMA e= ( N | NUMBER ) RPAREN
            {
            root_0 = (CommonTree)adaptor.nil();

            // Lucenedb.g:302:10: (not= 'NOT' )?
            int alt28=2;
            int LA28_0 = input.LA(1);

            if ( (LA28_0==40) ) {
                alt28=1;
            }
            switch (alt28) {
                case 1 :
                    // Lucenedb.g:302:10: not= 'NOT'
                    {
                    not=(Token)input.LT(1);
                    match(input,40,FOLLOW_40_in_between_expr1075); 
                    not_tree = (CommonTree)adaptor.create(not);
                    adaptor.addChild(root_0, not_tree);


                    }
                    break;

            }

            
                              if(not!=null){
                                   ((BetweenCondition)conditionRight).setNot(true);
                              }else{
                                   ((BetweenCondition)conditionRight).setNot(false);
                              }
                
                    
            string_literal57=(Token)input.LT(1);
            match(input,43,FOLLOW_43_in_between_expr1098); 
            string_literal57_tree = (CommonTree)adaptor.create(string_literal57);
            adaptor.addChild(root_0, string_literal57_tree);

            LPAREN58=(Token)input.LT(1);
            match(input,LPAREN,FOLLOW_LPAREN_in_between_expr1100); 
            LPAREN58_tree = (CommonTree)adaptor.create(LPAREN58);
            adaptor.addChild(root_0, LPAREN58_tree);

            s=(Token)input.LT(1);
            if ( input.LA(1)==N||input.LA(1)==NUMBER ) {
                input.consume();
                adaptor.addChild(root_0, adaptor.create(s));
                errorRecovery=false;
            }
            else {
                MismatchedSetException mse =
                    new MismatchedSetException(null,input);
                recoverFromMismatchedSet(input,mse,FOLLOW_set_in_between_expr1104);    throw mse;
            }

            ((BetweenCondition)conditionRight).setStart(s.getText());
            COMMA59=(Token)input.LT(1);
            match(input,COMMA,FOLLOW_COMMA_in_between_expr1113); 
            COMMA59_tree = (CommonTree)adaptor.create(COMMA59);
            adaptor.addChild(root_0, COMMA59_tree);

            e=(Token)input.LT(1);
            if ( input.LA(1)==N||input.LA(1)==NUMBER ) {
                input.consume();
                adaptor.addChild(root_0, adaptor.create(e));
                errorRecovery=false;
            }
            else {
                MismatchedSetException mse =
                    new MismatchedSetException(null,input);
                recoverFromMismatchedSet(input,mse,FOLLOW_set_in_between_expr1117);    throw mse;
            }

            ((BetweenCondition)conditionRight).setEnd(e.getText());
            RPAREN60=(Token)input.LT(1);
            match(input,RPAREN,FOLLOW_RPAREN_in_between_expr1124); 
            RPAREN60_tree = (CommonTree)adaptor.create(RPAREN60);
            adaptor.addChild(root_0, RPAREN60_tree);


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end between_expr

    public static class relational_op_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start relational_op
    // Lucenedb.g:317:1: relational_op : ( EQ | LTH | GTH | NOT_EQ | LEQ | GEQ );
    public final relational_op_return relational_op() throws RecognitionException {
        relational_op_return retval = new relational_op_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token set61=null;

        CommonTree set61_tree=null;

        try {
            // Lucenedb.g:318:2: ( EQ | LTH | GTH | NOT_EQ | LEQ | GEQ )
            // Lucenedb.g:
            {
            root_0 = (CommonTree)adaptor.nil();

            set61=(Token)input.LT(1);
            if ( (input.LA(1)>=EQ && input.LA(1)<=GEQ) ) {
                input.consume();
                adaptor.addChild(root_0, adaptor.create(set61));
                errorRecovery=false;
            }
            else {
                MismatchedSetException mse =
                    new MismatchedSetException(null,input);
                recoverFromMismatchedSet(input,mse,FOLLOW_set_in_relational_op0);    throw mse;
            }


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end relational_op

    public static class condition_left_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start condition_left
    // Lucenedb.g:321:1: condition_left : identifier ;
    public final condition_left_return condition_left() throws RecognitionException {
        condition_left_return retval = new condition_left_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        identifier_return identifier62 = null;



        try {
            // Lucenedb.g:322:2: ( identifier )
            // Lucenedb.g:322:4: identifier
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_identifier_in_condition_left1188);
            identifier62=identifier();
            _fsp--;

            adaptor.addChild(root_0, identifier62.getTree());

            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end condition_left

    public static class quoted_string_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start quoted_string
    // Lucenedb.g:326:1: quoted_string : QUOTED_STRING ;
    public final quoted_string_return quoted_string() throws RecognitionException {
        quoted_string_return retval = new quoted_string_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token QUOTED_STRING63=null;

        CommonTree QUOTED_STRING63_tree=null;

        try {
            // Lucenedb.g:327:2: ( QUOTED_STRING )
            // Lucenedb.g:327:4: QUOTED_STRING
            {
            root_0 = (CommonTree)adaptor.nil();

            QUOTED_STRING63=(Token)input.LT(1);
            match(input,QUOTED_STRING,FOLLOW_QUOTED_STRING_in_quoted_string1201); 
            QUOTED_STRING63_tree = (CommonTree)adaptor.create(QUOTED_STRING63);
            adaptor.addChild(root_0, QUOTED_STRING63_tree);


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        
        catch (RecognitionException ex) {
         reportError(ex);
          throw ex;
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end quoted_string


 

    public static final BitSet FOLLOW_selectStemtent_in_stemtent93 = new BitSet(new long[]{0x0000000000000000L});
    public static final BitSet FOLLOW_EOF_in_stemtent95 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_KW_SELECT_in_selectStemtent113 = new BitSet(new long[]{0x0000000000001020L});
    public static final BitSet FOLLOW_ASTERISK_in_selectStemtent117 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_selectList_in_selectStemtent119 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_KW_FROM_in_selectStemtent124 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_identifier_in_selectStemtent131 = new BitSet(new long[]{0x0000000A02002002L});
    public static final BitSet FOLLOW_sqlCondition_in_selectStemtent143 = new BitSet(new long[]{0x0000000A02000002L});
    public static final BitSet FOLLOW_groupby_in_selectStemtent155 = new BitSet(new long[]{0x0000000202000002L});
    public static final BitSet FOLLOW_orderby_in_selectStemtent166 = new BitSet(new long[]{0x0000000002000002L});
    public static final BitSet FOLLOW_limit_in_selectStemtent179 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_selectItem_in_selectList203 = new BitSet(new long[]{0x0000000000000082L});
    public static final BitSet FOLLOW_COMMA_in_selectList207 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_selectItem_in_selectList209 = new BitSet(new long[]{0x0000000000000082L});
    public static final BitSet FOLLOW_columnItem_in_selectItem264 = new BitSet(new long[]{0x0000000000001102L});
    public static final BitSet FOLLOW_KW_AS_in_selectItem268 = new BitSet(new long[]{0x0000000000001100L});
    public static final BitSet FOLLOW_identifier_in_selectItem275 = new BitSet(new long[]{0x0000000000001102L});
    public static final BitSet FOLLOW_identifier_in_columnItem318 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_functionColumnItem_in_columnItem341 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_identifier_in_functionColumnItem366 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_LPAREN_in_functionColumnItem368 = new BitSet(new long[]{0x0000000000205C80L});
    public static final BitSet FOLLOW_text_in_functionColumnItem372 = new BitSet(new long[]{0x0000000000000480L});
    public static final BitSet FOLLOW_COMMA_in_functionColumnItem379 = new BitSet(new long[]{0x0000000000205C80L});
    public static final BitSet FOLLOW_text_in_functionColumnItem383 = new BitSet(new long[]{0x0000000000000480L});
    public static final BitSet FOLLOW_RPAREN_in_functionColumnItem393 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_33_in_orderby430 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_orderStr_in_orderby434 = new BitSet(new long[]{0x0000000000000082L});
    public static final BitSet FOLLOW_COMMA_in_orderby439 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_orderStr_in_orderby441 = new BitSet(new long[]{0x0000000000000082L});
    public static final BitSet FOLLOW_identifier_in_orderStr480 = new BitSet(new long[]{0x0000000400001002L});
    public static final BitSet FOLLOW_34_in_orderStr486 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_identifier_in_orderStr491 = new BitSet(new long[]{0x0000000400001002L});
    public static final BitSet FOLLOW_identifier_in_orderStr503 = new BitSet(new long[]{0x0000000000001002L});
    public static final BitSet FOLLOW_35_in_groupby532 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_identifier_in_groupby536 = new BitSet(new long[]{0x0000000400000002L});
    public static final BitSet FOLLOW_34_in_groupby543 = new BitSet(new long[]{0x0000003000000000L});
    public static final BitSet FOLLOW_groupSort_in_groupby548 = new BitSet(new long[]{0x0000000400000002L});
    public static final BitSet FOLLOW_set_in_groupSort0 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_KW_LIMIT_in_limit596 = new BitSet(new long[]{0x0000000000000800L});
    public static final BitSet FOLLOW_N_in_limit601 = new BitSet(new long[]{0x0000000000000082L});
    public static final BitSet FOLLOW_COMMA_in_limit607 = new BitSet(new long[]{0x0000000000000800L});
    public static final BitSet FOLLOW_N_in_limit611 = new BitSet(new long[]{0x0000000000000082L});
    public static final BitSet FOLLOW_ID_in_identifier627 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_KW_WHERE_in_sqlCondition651 = new BitSet(new long[]{0x0000000000001200L});
    public static final BitSet FOLLOW_condition_or_in_sqlCondition653 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_condition_and_in_condition_or669 = new BitSet(new long[]{0x0000004000000002L});
    public static final BitSet FOLLOW_38_in_condition_or674 = new BitSet(new long[]{0x0000000000001200L});
    public static final BitSet FOLLOW_condition_and_in_condition_or678 = new BitSet(new long[]{0x0000004000000002L});
    public static final BitSet FOLLOW_condition_PAREN_in_condition_and693 = new BitSet(new long[]{0x0000008000000002L});
    public static final BitSet FOLLOW_39_in_condition_and698 = new BitSet(new long[]{0x0000000000001200L});
    public static final BitSet FOLLOW_condition_PAREN_in_condition_and700 = new BitSet(new long[]{0x0000008000000002L});
    public static final BitSet FOLLOW_LPAREN_in_condition_PAREN723 = new BitSet(new long[]{0x0000000000001200L});
    public static final BitSet FOLLOW_condition_or_in_condition_PAREN725 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_RPAREN_in_condition_PAREN728 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_condition_expr_in_condition_PAREN741 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_condition_left_in_condition_expr772 = new BitSet(new long[]{0x00000F00001F8000L});
    public static final BitSet FOLLOW_condition_right_in_condition_expr775 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_comp_expr_in_condition_right810 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_in_expr_in_condition_right826 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_like_expr_in_condition_right841 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_between_expr_in_condition_right856 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_relational_op_in_comp_expr875 = new BitSet(new long[]{0x0000000000204800L});
    public static final BitSet FOLLOW_value_in_comp_expr880 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_N_in_value898 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_NUMBER_in_value902 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_quoted_string_in_value906 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_N_in_text919 = new BitSet(new long[]{0x0000000000005802L});
    public static final BitSet FOLLOW_NUMBER_in_text923 = new BitSet(new long[]{0x0000000000005002L});
    public static final BitSet FOLLOW_ID_in_text927 = new BitSet(new long[]{0x0000000000001002L});
    public static final BitSet FOLLOW_quoted_string_in_text933 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_40_in_in_expr959 = new BitSet(new long[]{0x0000020000000000L});
    public static final BitSet FOLLOW_41_in_in_expr972 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_LPAREN_in_in_expr975 = new BitSet(new long[]{0x0000000000204800L});
    public static final BitSet FOLLOW_value_in_in_expr979 = new BitSet(new long[]{0x0000000000000480L});
    public static final BitSet FOLLOW_COMMA_in_in_expr983 = new BitSet(new long[]{0x0000000000204800L});
    public static final BitSet FOLLOW_value_in_in_expr987 = new BitSet(new long[]{0x0000000000000480L});
    public static final BitSet FOLLOW_RPAREN_in_in_expr993 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_40_in_like_expr1018 = new BitSet(new long[]{0x0000040000000000L});
    public static final BitSet FOLLOW_42_in_like_expr1041 = new BitSet(new long[]{0x0000000000200000L});
    public static final BitSet FOLLOW_quoted_string_in_like_expr1046 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_40_in_between_expr1075 = new BitSet(new long[]{0x0000080000000000L});
    public static final BitSet FOLLOW_43_in_between_expr1098 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_LPAREN_in_between_expr1100 = new BitSet(new long[]{0x0000000000004800L});
    public static final BitSet FOLLOW_set_in_between_expr1104 = new BitSet(new long[]{0x0000000000000080L});
    public static final BitSet FOLLOW_COMMA_in_between_expr1113 = new BitSet(new long[]{0x0000000000004800L});
    public static final BitSet FOLLOW_set_in_between_expr1117 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_RPAREN_in_between_expr1124 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_set_in_relational_op0 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_identifier_in_condition_left1188 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_QUOTED_STRING_in_quoted_string1201 = new BitSet(new long[]{0x0000000000000002L});

}